package com.cityfood.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cityfood.mapper.CfAttributeKeyMapper;
import com.cityfood.pojo.CfAttributeKey;
import com.cityfood.pojo.CfAttributeKeyExample;
import com.cityfood.pojo.CfAttributeKeyExample.Criteria;
import com.cityfood.service.AttributeKeyService;

@Service
public class AttributeKeyServiceImpl implements AttributeKeyService {
	
	@Autowired
	private CfAttributeKeyMapper keyMapper;

	@Override
	public List<CfAttributeKey> getAttributeKey(Integer categoryId) {
		CfAttributeKeyExample example = new CfAttributeKeyExample();
		Criteria criteria = example.createCriteria();
		criteria.andCategoryIdEqualTo(categoryId);
		List<CfAttributeKey> list = keyMapper.selectByExample(example);
		return list;
	}

	@Override
	public int insertAttributeKey(CfAttributeKey key) {
		key.setCreateTime(new Date());
		key.setUpdateTime(new Date());
		int i = keyMapper.insertSelective(key);
		return i;
	}

	@Override
	public int updateAttributeKey(CfAttributeKey key) {
		key.setUpdateTime(new Date());
		int i = keyMapper.updateByPrimaryKeySelective(key);
		return i;
	}

	@Override
	public int deleteAttributeKey(CfAttributeKey key) {
		key.setUpdateTime(new Date());
		int i = keyMapper.updateByPrimaryKeySelective(key);
		return i;
	}

}
